<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>面试反馈</title>
</head>
<body>
<div class="ui segment" id="n-page">
&nbsp;<br>
<!-- 所在城市  现任职位   工作状态+电话（电话一栏用***表示，包括自荐，猎头推荐及系统匹配）+推荐人&nbsp;<br/> -->
<c:choose>
    <c:when test="${interview.round == 6}">
        面试进展： 终面 </br>
    </c:when>
    <c:otherwise>
        面试进展： ${interview.round}面</br>
    </c:otherwise>
</c:choose>
    面试官信息：${interview.interviewer}<br>
    面试时间：${interview.interviewDate}<br>
    面试地点：${interview.interviewSite}<br>
    <input type="hidden" value="${interview.id}" id="interviewid">

<c:choose>
    <c:when test="${fn:length(interviewRecords) > 0}">
        <br><br>
        <h3 class="ui attached header" id="list-title">
            面试反馈历史记录
        </h3>
        &nbsp;<br>
        <c:forEach items="${interviewRecords}" var="iv">
            <c:if test="${iv.status != 1}">
                <div class="ui segment listitem">
                    面试类型：
                    <c:choose>
                        <c:when test="${iv.itype == 1}">
                            电话面试
                        </c:when>
                        <c:when test="${iv.itype == 2}">
                            公司面试
                        </c:when>
                        <c:when test="${iv.itype == 4}">
                            业务面试
                        </c:when>
                        <c:when test="${iv.itype == 5}">
                            人事面试
                        </c:when>
                        <c:when test="${iv.itype == 6}">
                            公司终面
                        </c:when>
                        <c:when test="${iv.itype == 7}">
                            谈薪资
                        </c:when>
                    </c:choose>

                    <br>面试结果：
                    <c:choose>
                        <c:when test="${iv.status == 2}">
                            建议继续面试
                        </c:when>
                        <c:when test="${iv.status == 3}">
                            拒绝
                        </c:when>
                        <c:when test="${iv.status == 4}">
                            录用
                        </c:when>
                        <c:when test="${iv.status == 6}">
                            未录用
                        </c:when>
                        <c:when test="${iv.status == 7}">
                            候选人拒绝
                        </c:when>
                        <c:when test="${iv.status == 8}">
                            候选人不合格
                        </c:when>
                        <c:when test="${iv.status == 9}">
                            薪资没谈拢
                        </c:when>
                        <c:when test="${iv.status == 10}">
                            入职
                        </c:when>
                        <c:when test="${iv.status == 11}">
                            未入职
                        </c:when>
                    </c:choose>
                    <br>备注： ${iv.remark}<br>
                </div>
            </c:if>
        </c:forEach>
    </c:when>
</c:choose>
    <BR><br>
    <h3 class="ui attached header" id="list-title">
        创建面试反馈
    </h3>
    &nbsp;<br>
        <div class="ui attached segment" id="list-items2">
            <form class="ui form" id="feedBackForm">
                <div class="field">
                    <label>选择日期</label>
                    <div class="ui input">
                        <input type="date" name="updatedate" id="updatedate" value="${todayStr}">
                    </div>
                </div>
                <div class="field">
                    <label>面试类型</label>
                    <select class="ui selection dropdown" id="itype" name="itype">
                        <option value="1">电话面试</option>
                        <option value="2">公司面试</option>
                        <!-- <option value="3">笔试</option> -->
                        <option value="4">业务面试</option>
                        <option value="5">人事面试</option>
                        <option value="6">公司终面</option>
                        <option value="7">谈薪资</option>
                    </select>
                </div>
                <div class="field">
                    <label>面试结果</label>
                    <select class="ui selection dropdown" id="status" name="status">
                        <option value="2">建议继续面试</option>
                        <option value="3">拒绝</option>
                        <option value="4">录用</option>
                        <option value="6">未录用</option>
                        <option value="7">候选人拒绝</option>
                        <option value="8">候选人不合格</option>
                        <option value="9">薪资没谈拢</option>
                        <option value="10">入职</option>
                        <option value="11">未入职</option>
                    </select>
                </div>
                <div class="field">
                    <label>反馈</label>
                    <div class="ui input">
                        <input type="text" name="remark" id="remark" placeholder="请输入反馈信息（必填项）" value="" >
                    </div>
                </div>
                <div class="ui segment" id="btn-next2">
                    <div class="fluid ui button submitBtn" id="next">确定</div>
                </div>
            </form>
        </div>

</div>
<script src="${ctx}/resources/jweixin-1.0.0.js"></script>
<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'hideOptionMenu']  
});

    var datasource = {

    };

    var handler = {      
        activate: function() {
            $(this).addClass('active').siblings().removeClass('active');
        }
    };
    
    function submitFeedBack(postdata){    	 
	     /*  var remark = $("#remark").val();
	      if(!remark || remark =="") {
	         alert("反馈是必填项");
	         return false;
	       } */
        var interviewid = $('#interviewid').val();
         var postUrl = '${ctx}/wechat/hunter/hr/creatInterview.do?interViewId=' + interviewid +'&recommendid='+${interview.recommendId};
         var that = this;

         $.ajax({
             url: postUrl,
             type: "POST",
             data: postdata,
             success:function(data, status) {
                 
            	 if(data.errorcode == 0 ) {
                     alert("操作成功")
                     location.reload();
                     <%--var getUrl = '${ctx}/wechat/hunter/hr/toInterview.do?recommendid='+${recommend.id};--%>
                     <%--location.href = getUrl--%>

                 } else {
                     alert(data.msg);
                 }
            	 
             },
         });
    }



    $(document).ready(function() {
           $(".submitBtn").click(function(){
        	   //提交表单
        	   var postData = {};

               var status = $("#status").val();
               var updatedate = $("#updatedate").val();
               var itype = $("#itype").val();
               var remark = $("#remark").val();

               postData['status'] = status;
               postData['updateTime'] = updatedate;
               postData['itype'] = itype;
               postData['remark'] = remark;

               submitFeedBack(postData);
           });
           
           $('.dropdown').dropdown({
               fullTextSearch:true,
           });

           var recommendstatus = $('#recommendstatus').val();
           if(recommendstatus == 0) {
               $('#next').addClass('disabled');
               $('#bonus').addClass('disabled');
           }else if(recommendstatus == 2){
                $('#bonus').addClass('disabled');
           }else if(recommendstatus == 6||
        		   recommendstatus == 8||
        		   recommendstatus == 9||recommendstatus == 11){
           	 // $('#next').addClass('disabled');//提交结果
             $('#bonus').addClass('disabled');//发放奖金
             $('#ask').addClass('disabled');//面试邀请--upd by adela 2019/12/24 @pony提出主动应聘的候选人，点击后加载页面均为有面试反馈的页面，且面试反馈记录、面试安排信息填写完成均可提交
           }else if(recommendstatus == 10){
           	 // $('#next').addClass('disabled');
             $('#ask').addClass('disabled');
           }else if(recommendstatus == 1||recommendstatus == 4||recommendstatus == 7){
        	 $('#bonus').addClass('disabled');//发放奖金
              /* $('#ask').addClass('disabled');//面试邀请 */
           }
           
          /*  $("#ask").click(function(){
             $("#list-items3").toggle();
           }); */
           
           var playerQT = document.getElementById("playerQT");  
           $("#playerBtn").bind("click",function(e){  
               var playerUrl = e.target.getAttribute("playerUrl");  
               playerAudio(playerUrl);  
           });  
           function playerAudio(url){  
               var html ="<audio class='icon-audio' id='player' style='margin:0 5px;cursor:pointer;' src='"+url+"' autoplay preload loop controls>播放</audio >";
               playerQT.innerHTML = html;  
           }
            
           wx.ready(function() {
        	   // document.getElementById('player').play();
           		//wx.hideOptionMenu();
           });
    });
    
    
</script>
</body>
</html>